//
//  HORepairerBaseInfoTableViewCell.m
//  微度报修
//
//  Created by foguo-mac-1 on 7/5/16.
//  Copyright © 2016 WeiDu. All rights reserved.
//

#import "HORepairerBaseInfoTableViewCell.h"
#import "HOUtils.h"

@interface HORepairerBaseInfoTableViewCell()
{
	
}
@property(nonatomic, assign)CGFloat height;
@property(nonatomic, retain)UILabel *departmentLbl;
@property(nonatomic, retain)UILabel *levelLbl;
@property(nonatomic, retain)UILabel *introductionLbl;

@end

@implementation HORepairerBaseInfoTableViewCell
- (void)initWithWidth:(CGFloat)width
{
	self.departmentLbl = [[[UILabel alloc]
						  initWithFrame:CGRectMake(HO_HORIZONAL_PADDING,
												   HO_HORIZONAL_PADDING,
												   width - 2 * HO_HORIZONAL_PADDING,
												   22)] autorelease];
	self.departmentLbl.font = [UIFont systemFontOfSize:15];
	self.departmentLbl.textColor = TEXT_COLOR_666666;
	[self.contentView addSubview:self.departmentLbl];
	
	self.levelLbl = [[[UILabel alloc]
						   initWithFrame:CGRectMake(HO_HORIZONAL_PADDING,
													HO_HORIZONAL_PADDING + 25,
													width - 2 * HO_HORIZONAL_PADDING,
													22)] autorelease];
	self.levelLbl.font = [UIFont systemFontOfSize:15];
	self.levelLbl.textColor = TEXT_COLOR_666666;
	[self.contentView addSubview:self.levelLbl];
	
	self.introductionLbl = [[[UILabel alloc]
						   initWithFrame:CGRectMake(HO_HORIZONAL_PADDING,
													3 + 50,
													width - 2 * HO_HORIZONAL_PADDING,
													300)] autorelease];
	self.introductionLbl.font = [UIFont systemFontOfSize:13];
	self.introductionLbl.textColor = TEXT_COLOR_999999;
	self.introductionLbl.numberOfLines = 0;
	[self.contentView addSubview:self.introductionLbl];
	
}
- (void)dealloc
{
	self.departmentLbl = nil;
	self.levelLbl = nil;
	self.introductionLbl = nil;
	[super dealloc];
}

- (CGFloat)getCellHeight
{
	return self.height;
}

- (void)setEntity:(HORepairerEntity *)entity
{
	self.departmentLbl.text = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"科室分工：", @"科室分工："),  [HOUtils getValideString:entity.depName]];
	self.levelLbl.text = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"职称：", @"职称："),  [HOUtils getValideString:entity.level]];
	self.introductionLbl.text = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"简介：", @"简介："),  [HOUtils getValideString:entity.introduce]];
	if([HOUtils getValideString:entity.introduce].length > 0)
	{
		[self.introductionLbl sizeToFit];
		self.introductionLbl.frame = CGRectMake(HO_HORIZONAL_PADDING,
												3 + 50,
												self.introductionLbl.frame.size.width,
												MAX(self.introductionLbl.frame.size.height, 22));
		self.height = self.introductionLbl.frame.size.height + self.introductionLbl.frame.origin.y + HO_HORIZONAL_PADDING;
	}
	else
	{
		self.introductionLbl.text = @"";
		self.height = self.levelLbl.frame.size.height + self.levelLbl.frame.origin.y + HO_HORIZONAL_PADDING;
	}
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
